package com.haofengsoft.scce.ui.consultation;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.haofengsoft.scce.R;
import com.haofengsoft.scce.ui.fragment.BaseFragment;

/**
 * Created by admin on 2015/7/20.
 */
public class LiveFragment extends BaseFragment {
    private WebSettings settings;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View view = inflater.inflate(R.layout.consultation_live, container,
                false);
        view.setOnTouchListener(new DontSpillOnTouchListener());
        //
        WebView webView = (WebView) view.findViewById(R.id.info_focus_new_ptrwv);
        settings = webView.getSettings();
        settings.setUseWideViewPort(true);
        // settings.setSupportZoom(true);
        settings.setLoadWithOverviewMode(true);
        settings.setDefaultTextEncodingName("UTF-8");
        settings.setJavaScriptEnabled(true);
        webView.setWebViewClient(new SampleWebViewClient());
        webView.loadUrl("http://sj.haofengsoft.com/zhibo.aspx");

        return view;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    public static LiveFragment newInstance(String name) {
        Bundle bundle = new Bundle();
        bundle.putString("name", name);
        LiveFragment fragment = new LiveFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

    }

    @Override
    protected void lazyLoad() {

    }

    private static class SampleWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }
}